package com.dody.agile.payment.schedule;


import com.dody.agile.payment.utils.DateUtils;

import java.util.Calendar;
import java.util.Date;

/**
 * @author ShiXin
 * @date 2019/4/11 20:05
 * @description agile
 */
public class BiweeklySchedule implements PaymentSchedule{


    @Override
    public boolean isPayDay(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(2019, Calendar.APRIL, 12);
        Date prePayableFriday = calendar.getTime();

        Calendar calendar1 = Calendar.getInstance();
        calendar1.setTime(date);
        int x = calendar1.get(Calendar.DATE)-calendar.get(Calendar.DATE);
        return x == 14;
    }

    @Override
    public Date getPayPeriodStartDate(Date d) {
        return DateUtils.add(d,-14);
    }

    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(2019, Calendar.APRIL, 26);

        BiweeklySchedule biweeklySchedule = new BiweeklySchedule();
        System.out.println(biweeklySchedule.isPayDay(calendar.getTime()));
    }
}
